package cn.com.huzo.repository.financial.impl;

import cn.com.huzo.model.entities.financial.AccoutingPeriodEntity;
import cn.com.huzo.repository.financial.AccoutingPeriodRepository;
import huzofw.repository.impl.GenericRepositoryImpl;
import huzofw.repository.impl.MyBatisDaoUtils;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;

/**
 * 会计期数据访问对象。
 *
 * @author 吴旭
 */
@Repository("AccoutingPeriodRepository")
public class AccoutingPeriodRepositoryImpl extends GenericRepositoryImpl<AccoutingPeriodEntity, String>
        implements AccoutingPeriodRepository {

    private final String namespace = "cn.com.huzo.repository.financial.AccoutingPeriodRepository";

    /**
     * 构造函数,设置the instance to LeaveApplicationRepositoryImpl.class.
     */
    public AccoutingPeriodRepositoryImpl() {
        super(AccoutingPeriodEntity.class);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public List<String> fetchAllApYear() {
        return getSqlSession().selectList(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchAllApYear"));
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String fetchLastApYear() {
        return getSqlSession().selectOne(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchLastApYear"));
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public List<AccoutingPeriodEntity> fetchByApYear(String apYear) {
        return getSqlSession().selectList(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchByApYear"), apYear);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer bulk_insert(List<Map<String, Object>> itemList) {
        return getSqlSession().insert(MyBatisDaoUtils.getMapperQueryId(
                namespace, "bulk_insert"), itemList);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer batchInsert(List<AccoutingPeriodEntity> itemList) {
        return getSqlSession().insert(MyBatisDaoUtils.getMapperQueryId(
                namespace, "batchInsert"), itemList);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer delete(String apyear) {
        return getSqlSession().delete(MyBatisDaoUtils.getMapperQueryId(
                namespace, "delete"), apyear);
    }
}
